home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH11 / EX11_1.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-13  |  1.3 KB  |  82 lines

  1.  
  2. extern "C" void GotoXY(unsigned y, unsigned x);
  3. extern "C" void GetXY(unsigned &x, unsigned &y);
  4. extern "C" void ClrScrn();
  5. extern "C" int tstKbd();
  6. extern "C" void Capture(unsigned ScrCopy[25][80]);
  7. extern "C" void PutScr(unsigned ScrCopy[25][80]);
  8. extern "C" void PutChar(char ch);
  9. extern "C" void PutStr(char *ch);
  10.  
  11. int main()
  12. {
  13.     unsigned     SaveScr[25][80];
  14.  
  15.     int         dx,
  16.                 x,
  17.                 dy,
  18.                 y;
  19.  
  20.     long        i;
  21.  
  22.     unsigned    savex,
  23.                 savey;
  24.  
  25.  
  26.  
  27.     GetXY(savex, savey);
  28.     Capture(SaveScr);
  29.     ClrScrn();
  30.  
  31.     GotoXY(24,0);
  32.     PutStr("Press any key to quit");
  33.  
  34.     dx = 1;
  35.     dy = 1;
  36.     x = 1;
  37.     y = 1;
  38.     while (!tstKbd())
  39.     {
  40.  
  41.     GotoXY(y, x);
  42.         PutChar('#');
  43.  
  44.         for (i=0; i<500000; ++i);
  45.  
  46.         GotoXY(y, x);
  47.         PutChar(' ');
  48.  
  49.  
  50.  
  51.     x += dx;
  52.         y += dy;
  53.         if (x >= 79)
  54.     {
  55.             x = 78;
  56.             dx = -1;
  57.     }
  58.         else if (x <= 0)
  59.     {
  60.             x = 1;
  61.             dx = 1;
  62.     }
  63.  
  64.         if (y >= 24)
  65.     {
  66.             y = 23;
  67.             dy = -1;
  68.     }
  69.         else if (y <= 0)
  70.     {
  71.             y = 1;
  72.             dy = 1;
  73.     }
  74.  
  75.  
  76.     }
  77.  
  78.     PutScr(SaveScr);
  79.     GotoXY(savey, savex);
  80.     return 0;
  81. }
  82.